package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/goredis"
	"fmt"
)


type TestRedisController struct {
	beego.Controller
}

func (c *TestRedisController) Get() {
	var client goredis.Client
	client.Addr = beego.AppConfig.String("redis_host")

	//写入test
	err := client.Set("test", []byte("hello world."))
	if err != nil{
		panic(err)
	}

	//读取test
	res, err := client.Get("test")
	if err != nil {
		panic(err)
	}

	fmt.Println(string(res))

	//test hmset
	f := make(map[string]interface{})
	f["name"] = "zhangsan";
	f["age"] = 12;
	f["sex"] = "male";

	err = client.Hmset("test_hash", f)
	if err != nil {
		panic(err)
	}

	//test zset
	//err = client.Zadd("test_zset", []byte("influx"), 100)
	//if err != nil {
	//	panic(err)
	//}


	/*
		查出zset数据
		type test_zset
		zrange test_zset 0 -1
	*/

}


func (c *TestRedisController) Post() {

}

